package com.kongwg.exer;

import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.*;

/**
 * @author kongwg
 * @create 2020-12-18 9:17
 */
public class Day09Demo {

    @Test
    public void test() {
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        map.put("AA", 123);
        map.put("EE", 244);
        map.put("DD", 125);
        map.put("CC", 567);

        Set<String> strings = map.keySet();
        for (String s : strings) {
            System.out.println(s);
        }
        Collection<Integer> values = map.values();
        for (Integer i : values) {
            System.out.println(i);
        }
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        Iterator<Map.Entry<String, Integer>> iterator = entries.iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, Integer> next = iterator.next();
            String key = next.getKey();
            Integer value = next.getValue();

            System.out.println(key + " --" + value);
        }
    }


    @Test
    public void test1() {
        HashMap<String, String> map = new HashMap<>();
        List<String> list = new ArrayList<>();
        map.put("AA", "aa");
        map.put("BB", "bb");
        map.put("CC", "cc");

        Collection<String> values = map.values();
        for (String s : values) {
            list.add(s);
        }
        System.out.println(list);

//        map.put();
    }

    @Test
    public void test2() throws IOException {
        File file = new File("f:/io/a.txt");
        File file1 = new File(file.getParent(), "b.txt");
        file1.createNewFile();

    }
    /**
     * map接口中常用的方法
     * 增put()
     * 删remove()
     * 改put(string key,string value)
     * 查get()
     * 长度size()
     * 遍历keySet()/valueSet()/values()/entrySet()
     */


    @Test
    public void test4() {



    }


}
